/**
 * 
 */
package gui.text;

import javax.swing.text.BadLocationException;
import javax.swing.text.Element;

/**
 * Indicates that an Element can be split.
 * 
 * @author Joshua Lockerman
 * @param <Type> the type of the Element to be split.
 *
 */
public interface Splittable<Type extends Splittable> extends Element {
    /**
     * Splits the element, and any Splitable children it may possess, 
     * at modelPosition in the underlying document. Normally the old Element is the second Element of the array.
     * @param modelPosition the point at which the Element should be split. 
     * @return an array the first element of which is the part of the the Element before
     * the modelPosition the second element the part after the modelPostion. 
     * @throws BadLocationException if the modelPosition is not a valid splitting point </br> 
     * ie: if the modelPosition is not in the document, the Element, or the startOffset or endOffset of the Element
     */
    public Type[] split(int modelPosition) throws BadLocationException;
}
